/*
 * 上海远境文化传媒有限公司 版权所有
 */
package controllers.api;

import facade.open.BaseJsonAPI;
import helper.DateTimeFormater;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 返回服务器日期时间的接口
 */
public class DateTimeAPI extends BaseJsonAPI {

    public static void execute() {
        Map<String, String> result = new HashMap<>();
        Date now = new Date();
        result.put("datetime", DateTimeFormater.dt(now));
        result.put("date", DateTimeFormater.date(now));
        result.put("time", DateTimeFormater.time(now));
        renderJSON(result);
    }

    public static void executeV2() {
        Map<String, String> result = new HashMap<>();
        Date now = new Date();
        result.put("date", DateTimeFormater.date(now));
        result.put("time", DateTimeFormater.time(now));
        result.put("datetime", DateTimeFormater.dt(now));
        renderData(result);
    }
}
